﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using SharpArch.Domain.PersistenceSupport;
using SharpArch.NHibernate;
using SharpArch.NHibernate.Contracts.Repositories;

namespace ExBlogger.Tests.Unity {
    internal class ComponentRegistrar {
        public static void AddComponentsTo(IUnityContainer container) {
            AddGenericRepositoriesTo(container);
        }

        private static void AddGenericRepositoriesTo(IUnityContainer container) {
            container.RegisterType(typeof(IEntityDuplicateChecker), typeof(EntityDuplicateChecker), new ContainerControlledLifetimeManager());
            container.RegisterType(typeof(ISessionFactoryKeyProvider), typeof(DefaultSessionFactoryKeyProvider), new ContainerControlledLifetimeManager());
            container.RegisterType(typeof(IRepository<>), typeof(NHibernateRepository<>), new ContainerControlledLifetimeManager());
            container.RegisterType(typeof(INHibernateRepository<>), typeof(NHibernateRepository<>), new ContainerControlledLifetimeManager());
            container.RegisterType(typeof(INHibernateRepositoryWithTypedId<,>), typeof(NHibernateRepositoryWithTypedId<,>), new ContainerControlledLifetimeManager());
            container.RegisterType(typeof(INHibernateRepositoryWithTypedId<,>), typeof(NHibernateRepositoryWithTypedId<,>), new ContainerControlledLifetimeManager());
        }
    }
}
